/*
	This file is part of AVRCppLib.

    AVRCppLib is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    AVRCppLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AVRCppLib.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) Maxime Lemonnier 2007-2011
 */

#ifndef TimerOutputCompareModes_H_
#define TimerOutputCompareModes_H_

namespace Timers
{

namespace CompareModes
{
	/*!
	 * Compare modes available
	 */
	enum CompareMode{

		NORMAL_OC_PIN_DISCONNECTED = 0x00,		//!< the timer counts from 0x00 to TOP and overflows to 0x00
		TOGGLE_OC_PIN_ON_COMPARE_MATCH = 0x01,	//!< the timer counts from 0x00 to TOP and overflows to 0x00 @warning use with WaveGenerationMode::NORMAL_COMPARE_MODE_BEHAVIOUR \b only!

		/*!
		 * The behaviour depends on WaveGenerationMode
		 * - WaveGenerationMode::NORMAL_COMPARE_MODE_BEHAVIOUR : Ocn pin is cleared on compare match (not very useful)
		 * - WaveGenerationMode::PWM_PHASE_CORRECT : Ocn pin is cleared on compare match, set at 0x00
		 * 	- 	this mode will generate a PWM signal with frequency \f$ PWM_{freq} =  \frac	{freq_{clockSource}}	{\left(	\mathsf{prescaler} * 256 \right)} \f$
		 * 		and lenght \f$ frac	{\frac	{\mathsf{compareToValue}}	{\mathsf{getTopValue()}}	}	{PWM_{freq}} \f$
		 * - WaveGenerationMode::PWM_FAST : Ocn pin is cleared on compare match when couting up, set on compare match when couting down
		 *	- 	this mode will generate a PWM signal with frequency \f$ PWM_{freq} =  \frac	{freq_{clockSource}}	{\left(	\mathsf{prescaler} * 510 \right)} \f$
		 * 		and lenght \f$ frac	{\frac	{\mathsf{compareToValue}}	{\mathsf{getTopValue()}}	}	{PWM_{freq}} \f$
		 */
		CLEAR_OC_PIN_ON_COMPARE_MATCH = 0x02,

		/*!
		 * The behaviour depends on WaveGenerationMode
		 * - WaveGenerationMode::NORMAL_COMPARE_MODE_BEHAVIOUR : Ocn pin is set on compare match (not very useful)
		 * - WaveGenerationMode::PWM_PHASE_CORRECT : Ocn pin is set on compare match, cleared at 0x00
		 * 	- 	this mode will generate a PWM signal with frequency \f$ PWM_{freq} =  \frac	{freq_{clockSource}}	{\left(	\mathsf{prescaler} * 256 \right)} \f$
		 * 		and lenght \f$ frac	{\frac	{1 - \mathsf{compareToValue}}	{\mathsf{getTopValue()}}	}	{PWM_{freq}} \f$
		 * - WaveGenerationMode::PWM_FAST : Ocn pin is cleared on compare match when couting down, set on compare match when couting up
		 *	- 	this mode will generate a PWM signal with frequency \f$ PWM_{freq} =  \frac	{freq_{clockSource}}	{\left(	\mathsf{prescaler} * 510 \right)} \f$
		 * 		and lenght \f$ frac	{\frac	{1 - \mathsf{compareToValue}}	{\mathsf{getTopValue()}}	}	{PWM_{freq}} \f$
		 *
		 */
		SET_OC_PIN_ON_COMPARE_MATCH = 0x03
	};
}

}
#endif /* TimerOutputCompareModes_H_ */
